<template>
  <div>
    <!-- 列表导出配置->自定义样式类 -->
    <p>导出自定义样式类继承接口：cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler.java</p>
    <p>接口源码：</p>
    <pre>
      public interface IExcelExportStyler {

        /**
         * 列表头样式
         */
        public CellStyle getHeaderStyle(short headerColor);

        /**
         * 标题样式
         */
        public CellStyle getTitleStyle(short color);

        /**
         * 获取样式方法
         */
        @Deprecated
        @Removal(
                version = "4.2"
        )
        public CellStyle getStyles(boolean parity, ExcelExportEntity entity);

        /**
         * 获取样式方法
         *
         * @param dataRow 数据行
         * @param obj     对象
         * @param data    数据
         */
        public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data);

        /**
         * 模板使用的样式设置
         */
        public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams);
    }
    </pre>
    <p>自定义样式类示例：</p>
    <pre>
      import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
      import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
      import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
      import org.apache.poi.hssf.util.HSSFColor;
      import org.apache.poi.ss.usermodel.*;

      public class ExcelExportStylerExt1 implements IExcelExportStyler {
          protected Workbook workbook;
          public ExcelExportStylerExt1(Workbook workbook) {
              this.workbook = workbook;
          }
          @Override
          public CellStyle getTitleStyle(short color) {
              CellStyle titleStyle = this.workbook.createCellStyle();
              titleStyle.setAlignment(HorizontalAlignment.CENTER);
              titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
              titleStyle.setFillForegroundColor(color);
              titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
              titleStyle.setWrapText(true);
              return titleStyle;
          }
          @Override
          public CellStyle getHeaderStyle(short color) {
              CellStyle titleStyle = workbook.createCellStyle();
              titleStyle.setFillForegroundColor(color);
              titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
              Font font = workbook.createFont();
              font.setFontHeightInPoints((short) 12);
              titleStyle.setFont(font);
              titleStyle.setAlignment(HorizontalAlignment.CENTER);
              titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
              return titleStyle;
          }
          @Override
          public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
              CellStyle style = workbook.createCellStyle();
              style.setAlignment(HorizontalAlignment.CENTER);
              style.setVerticalAlignment(VerticalAlignment.CENTER);
              if (entity!=null && entity.isWrap()) {
                  style.setWrapText(true);
              }
              //设置背景色 颜色值使用常量 HSSFColor.HSSFColorPredefined
              style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.SKY_BLUE.getIndex());
              style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
              return style;
          }
          @Override
          public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data) {
              return null;
          }
          @Override
          public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams) {
              return null;
          }
      }
    </pre>
  </div>
</template>
